package org.cfg;

import com.sojoys.artifact.build.data.base.BaseCfg;
import com.sojoys.artifact.tools.ToolMap;
import com.sojoys.artifact.tools.ToolCopy;
import com.sojoys.artifact.factory.bytebuff.IByteBuff;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import java.util.HashMap;
import com.sojoys.artifact.constant.DataModelKeyEnum;
import java.util.ArrayList;
/**
 * 建筑
 */
public class BuildCfg extends BaseCfg<BuildCfg> {

	/**
	 * 数据库表名称
	 */
	public static final String TABLE_NAME = "build";
	/**
	 * 完整类名称
	 */
	public static final String CLASS_NAME = "org.cfg.BuildCfg"; 
	/**
	 * 字段个数
	 */
	public static final int COLUMN_COUNT= 13;
	/**
	 * 数据库源字段注释
	 */
	public static final String[] SOURCE_COLUMN_REMARKS = new String[]{"","建筑编号","建筑等级","解锁条件","升级条件","升级消耗","升级所需时间","打工槽位","打工要求","打工时间","收益周期","城市id","商店类型",};
	/**
	 * 数据库源字段名字
	 */
	public static final String[] SOURCE_COLUMN_NAMES = new String[]{"id","buildId","level","openType","upType","consume","needTime","position","demand","workTime","cycle","cityId","shopType",};
	/**
	 * 拼音字段名字
	 */
	public static final String[] PINGYING_COLUMN_NAMES = new String[]{"id","buildId","level","openType","upType","consume","needTime","position","demand","workTime","cycle","cityId","shopType",};
	/**
	 * HashCode字段名字
	 */
	public static final Integer[] HASHCODE_COLUMN_NAMES = new Integer[]{3355,230943785,102865796,-504630108,-839299979,951516156,865670275,747804969,-1335432629,34839934,95131878,-1360137242,-345279664,};
	/**
	 * 字段基本类型
	 */
	public static final String[] COLUMN_BASICTYPES = new String[]{"int","int","int","Map","Map","Map","int","int","Map","int","int","int","int",};
	/**
	 * 字段引用类型
	 */
	public static final Class[] COLUMN_CLASSTYPES = new Class[]{Integer.class,Integer.class,Integer.class,Map.class,Map.class,Map.class,Integer.class,Integer.class,Map.class,Integer.class,Integer.class,Integer.class,Integer.class,};
	
	/**
	 * id
	 */
	private int id;
	
	/**
	 * 建筑编号
	 */
	private int buildId;
	
	/**
	 * 建筑等级
	 */
	private int level;
	
	/**
	 * 解锁条件
	 */
	private Map openType;
	
	/**
	 * 升级条件
	 */
	private Map upType;
	
	/**
	 * 升级消耗
	 */
	private Map consume;
	
	/**
	 * 升级所需时间
	 */
	private int needTime;
	
	/**
	 * 打工槽位
	 */
	private int position;
	
	/**
	 * 打工要求
	 */
	private Map demand;
	
	/**
	 * 打工时间
	 */
	private int workTime;
	
	/**
	 * 收益周期
	 */
	private int cycle;
	
	/**
	 * 城市id
	 */
	private int cityId;
	
	/**
	 * 商店类型
	 */
	private int shopType;
	
	
	
	public static BuildCfg builder() {
		BuildCfg buildCfg = new BuildCfg();
		return buildCfg;
	}
	
	/**
	 * id
	 */
	public int getId() {
		return id;
	}
	
	/**
	 * 建筑编号
	 */
	public int getBuildId() {
		return buildId;
	}
	
	/**
	 * 建筑等级
	 */
	public int getLevel() {
		return level;
	}
	
	/**
	 * 解锁条件
	 */
	public Map getOpenType() {
		return openType;
	}
	
	/**
	 * 升级条件
	 */
	public Map getUpType() {
		return upType;
	}
	
	/**
	 * 升级消耗
	 */
	public Map getConsume() {
		return consume;
	}
	
	/**
	 * 升级所需时间
	 */
	public int getNeedTime() {
		return needTime;
	}
	
	/**
	 * 打工槽位
	 */
	public int getPosition() {
		return position;
	}
	
	/**
	 * 打工要求
	 */
	public Map getDemand() {
		return demand;
	}
	
	/**
	 * 打工时间
	 */
	public int getWorkTime() {
		return workTime;
	}
	
	/**
	 * 收益周期
	 */
	public int getCycle() {
		return cycle;
	}
	
	/**
	 * 城市id
	 */
	public int getCityId() {
		return cityId;
	}
	
	/**
	 * 商店类型
	 */
	public int getShopType() {
		return shopType;
	}
	
	
	protected Object[] getColumnNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return SOURCE_COLUMN_NAMES;
		case PINGYING:
			return PINGYING_COLUMN_NAMES;
		case HASHCODE:
			return HASHCODE_COLUMN_NAMES;
		case REMARKS:
			return SOURCE_COLUMN_REMARKS;
		default:
			return PINGYING_COLUMN_NAMES;
		}
	}
	
	protected String[] getBasicTypes(){
		return COLUMN_BASICTYPES;
	}
	
	protected Class[] getClassTypes(){
		return COLUMN_CLASSTYPES;
	}
	
	protected Object[] getColumeValues(){
		Object[] values = new Object[COLUMN_COUNT];
        values[0] = this.id;
        values[1] = this.buildId;
        values[2] = this.level;
        values[3] = this.openType;
        values[4] = this.upType;
        values[5] = this.consume;
        values[6] = this.needTime;
        values[7] = this.position;
        values[8] = this.demand;
        values[9] = this.workTime;
        values[10] = this.cycle;
        values[11] = this.cityId;
        values[12] = this.shopType;
        return values;
	}
	
	protected BuildCfg createColumeValues(Object[] vals) {
		this.id = (int)vals[0];
		this.buildId = (int)vals[1];
		this.level = (int)vals[2];
		this.openType = (Map)vals[3];
		this.upType = (Map)vals[4];
		this.consume = (Map)vals[5];
		this.needTime = (int)vals[6];
		this.position = (int)vals[7];
		this.demand = (Map)vals[8];
		this.workTime = (int)vals[9];
		this.cycle = (int)vals[10];
		this.cityId = (int)vals[11];
		this.shopType = (int)vals[12];
		return this;
	}
	
	protected Map<Object, Object> toMap(Object[] keys,Map<Object, Object> map){
        map.put(keys[0], this.id);
        map.put(keys[1], this.buildId);
        map.put(keys[2], this.level);
        map.put(keys[3], this.openType);
        map.put(keys[4], this.upType);
        map.put(keys[5], this.consume);
        map.put(keys[6], this.needTime);
        map.put(keys[7], this.position);
        map.put(keys[8], this.demand);
        map.put(keys[9], this.workTime);
        map.put(keys[10], this.cycle);
        map.put(keys[11], this.cityId);
        map.put(keys[12], this.shopType);
        return map;
    }
    
    protected BuildCfg createForMap(Object[] keys,Map map){
   		this.id = (int)map.get(keys[0]);
   		this.buildId = (int)map.get(keys[1]);
   		this.level = (int)map.get(keys[2]);
   		this.openType = (Map)map.get(keys[3]);
   		this.upType = (Map)map.get(keys[4]);
   		this.consume = (Map)map.get(keys[5]);
   		this.needTime = (int)map.get(keys[6]);
   		this.position = (int)map.get(keys[7]);
   		this.demand = (Map)map.get(keys[8]);
   		this.workTime = (int)map.get(keys[9]);
   		this.cycle = (int)map.get(keys[10]);
   		this.cityId = (int)map.get(keys[11]);
   		this.shopType = (int)map.get(keys[12]);
        return this;
    }
	
	
	protected JSONObject toJSONObject(Object[] keys,JSONObject obj){
        obj.put(keys[0], this.id);
        obj.put(keys[1], this.buildId);
        obj.put(keys[2], this.level);
        obj.put(keys[3], this.openType);
        obj.put(keys[4], this.upType);
        obj.put(keys[5], this.consume);
        obj.put(keys[6], this.needTime);
        obj.put(keys[7], this.position);
        obj.put(keys[8], this.demand);
        obj.put(keys[9], this.workTime);
        obj.put(keys[10], this.cycle);
        obj.put(keys[11], this.cityId);
        obj.put(keys[12], this.shopType);
        return obj;
    }
    
    protected BuildCfg createForJSONObject(Object[] keys,JSONObject obj){
	    this.id = obj.getIntValue(keys[0]);
	    this.buildId = obj.getIntValue(keys[1]);
	    this.level = obj.getIntValue(keys[2]);
		this.openType = obj.getObject(keys[3],Map.class);
		this.upType = obj.getObject(keys[4],Map.class);
		this.consume = obj.getObject(keys[5],Map.class);
	    this.needTime = obj.getIntValue(keys[6]);
	    this.position = obj.getIntValue(keys[7]);
		this.demand = obj.getObject(keys[8],Map.class);
	    this.workTime = obj.getIntValue(keys[9]);
	    this.cycle = obj.getIntValue(keys[10]);
	    this.cityId = obj.getIntValue(keys[11]);
	    this.shopType = obj.getIntValue(keys[12]);
        return this;
    }
    
    protected void writeBytes(IByteBuff byteBuf){
	    byteBuf.writeInt(this.id);
	    byteBuf.writeInt(this.buildId);
	    byteBuf.writeInt(this.level);
	    byteBuf.writeObject(this.openType);
	    byteBuf.writeObject(this.upType);
	    byteBuf.writeObject(this.consume);
	    byteBuf.writeInt(this.needTime);
	    byteBuf.writeInt(this.position);
	    byteBuf.writeObject(this.demand);
	    byteBuf.writeInt(this.workTime);
	    byteBuf.writeInt(this.cycle);
	    byteBuf.writeInt(this.cityId);
	    byteBuf.writeInt(this.shopType);
    }
	
	protected BuildCfg readBytes(IByteBuff byteBuf){
	    this.id = byteBuf.readInt(null);
	    this.buildId = byteBuf.readInt(null);
	    this.level = byteBuf.readInt(null);
	    this.openType = (Map)byteBuf.readObject();
	    this.upType = (Map)byteBuf.readObject();
	    this.consume = (Map)byteBuf.readObject();
	    this.needTime = byteBuf.readInt(null);
	    this.position = byteBuf.readInt(null);
	    this.demand = (Map)byteBuf.readObject();
	    this.workTime = byteBuf.readInt(null);
	    this.cycle = byteBuf.readInt(null);
	    this.cityId = byteBuf.readInt(null);
	    this.shopType = byteBuf.readInt(null);
	    return this;
	}
	
	public BuildCfg deepCopy(){
		BuildCfg buildCfg = null;
		try {
			buildCfg = (BuildCfg) super.clone();
		    buildCfg.openType = ToolCopy.copyObject(this.openType);
		    buildCfg.upType = ToolCopy.copyObject(this.upType);
		    buildCfg.consume = ToolCopy.copyObject(this.consume);
		    buildCfg.demand = ToolCopy.copyObject(this.demand);
			return buildCfg;
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return buildCfg;
	}
//自定义内容起始位置
//自定义内容结束位置
}
